import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
import { ErrorStateMatcher } from '@angular/material/core';
import { DEGREE, Schedule } from '../model/schedule';

@Component({
  selector: 'app-schedule-save-dialog',
  templateUrl: './schedule-save.component.html',
  styleUrls: ['./schedule-save.component.scss']
})
export class ScheduleSaveDialogComponent {
  public options: FormGroup;
  public titleControl: FormControl = new FormControl('', [
    Validators.required,
    Validators.maxLength(50),
  ]);
  public contentControl: FormControl = new FormControl('', [
    Validators.required,
  ])
  public degrees = [
    [ DEGREE.SERIOURS_URGENT, '重要且紧急' ],
    [ DEGREE.SERIOURS_NOT_URGENT,'重要不紧急' ],
    [ DEGREE.NOT_SERIOURS_URGENT, '紧急不重要' ],
    [ DEGREE.NOT_SERIOURS_NOT_URGENT, '不重要不紧急' ],
  ]
  public degree: DEGREE;
  public schedule: Schedule;
  // public categories: ScheduleCategory;
  constructor(
    public dialogRef: MatDialogRef<ScheduleSaveDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any,
    public fb: FormBuilder)
  {
    this.options = fb.group({
      'color': 'primary',
    });
    this.degree = DEGREE.SERIOURS_URGENT;
    this.schedule = new Schedule({
      category: 1
    });
  }

  onNoClick(): void {
    this.dialogRef.close();
  }
}
